import waves from "@/directive/waves";
import { mapGetters } from 'vuex';
import { getMapSettingList, setMapParams } from '../personnel-manage.service';
import { alertMessage } from '@/utils/utils'
export default {
  name: 'map-setting',
  components: {},
  directives: { waves },
  data() {
    return {
      data: [], // 列表数据
      loading: false,
      editDialogVisible: false, // 编辑详情模态窗
      editForm: {} // 编辑用户表单
    }
  },
  computed: {
    ...mapGetters([
      'codesCheck'
    ])
  },
  created() {
    this.getMapSetting();
  },
  methods: {
    // 获取地图设定
    getMapSetting() {
      const params = {
        pageNum: 1,
        recordNum: 10
      }
      this.loading = true
      getMapSettingList(params).then(res => {
        this.data = res.data;
        this.loading = false
      })
    },

    // 打开编辑弹窗
    openEditDialog(row) {
      this.editDialogVisible = true;
      this.editForm = JSON.parse(JSON.stringify(row));
    },

    // 保存
    save() {
      if (!this.editForm.startValue || !this.editForm.endValue) {
        alertMessage('阈值范围不能为空');
        return
      }
      setMapParams(this.editForm).then(res => {
        alertMessage(res.message)
        this.getMapSetting();
        this.editDialogVisible = false;
      })
    }
  }
}
